var babel = require('rollup-plugin-babel');
var { nodeResolve } = require('@rollup/plugin-node-resolve');
var commonjs = require('@rollup/plugin-commonjs');
var {terser} = require('rollup-plugin-terser');
const browserModule = require('../../browser');
const rollup = require('rollup');
console.log(nodeResolve)
const defaultInputOptions = {
  plugins: [
    nodeResolve(),
    commonjs(),
    terser(),
    babel({
      exclude: 'node_modules/**',
    }),
    // uglify()
  ],
};
const defaultOutputOptions = { format: 'iife' };

async function rollupBuild(inputOptions, outputOptions) {
  const bundle = await rollup.rollup({ ...defaultInputOptions, ...inputOptions });
  await bundle.write({ ...defaultOutputOptions, ...outputOptions });
  browserModule.reload();
}

module.exports = { rollupBuild };
